package dao

import (
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/postgres"
)

var (
	DB *gorm.DB
)

func InitPGSQL()(err error){
	DB, err = gorm.Open("postgres", "host=localhost port=5432 user=postgres dbname=bubble password=97301335 sslmode=disable TimeZone=Asia/Shanghai")
	if err != nil {
		return
	}

	return DB.DB().Ping() //测试连通性
}

func Close(){
	DB.Close() // 程序退出
}